home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / bbbbs85.lha / rexx / bbsProfiles.rexx < prev    next >
OS/2 REXX Batch file  |  1994-12-21  |  6KB  |  311 lines

  1. /* $VER: bbsProfiles.rexx 8.3 (21.12.94)
  2. Copyright ⌐ 1994 Richard Lee Stockton
  3. BBBBS Profiles manager
  4. FREELY DISTRIBUTABLE
  5. */
  6.  
  7. OPTIONS RESULTS
  8. SIGNAL ON BREAK_C
  9. SIGNAL ON BREAK_E
  10.  
  11. PARSE ARG name level sysoplevel linesperpage colorflag maxtime bbspath .
  12.  
  13. CALL TIME('R')
  14.  
  15. def=''
  16. pen3=''
  17. bak2=''
  18. IF colorflag=0 THEN
  19.   DO
  20.     def=''
  21.     pen3=''
  22.     bak2=''
  23.   END
  24. CR=''
  25. frombb=0
  26. IF ADDRESS()='BAUD' THEN
  27.   DO
  28.     CR='0D'x
  29.     frombb=1
  30.   END
  31. prodir=bbspath'Profiles'
  32. CALL MAKEDIR(prodir)
  33. pros=SHOWDIR(prodir)
  34. protxt=bbspath'BBS_TEXT/PROFILES'
  35. CALL showtext(protxt 1)
  36. DO lupe=1
  37.   SAY CR
  38.   SAY '       1. Edit 'name'''s user Profile'CR
  39.   SAY '       2. View a User Profile'CR
  40.   SAY '       3. Search User Profiles'CR
  41.   SAY '       4. Browse User Profiles'CR
  42.   SAY CR
  43.   temp=getinput(1 1 'Enter Selection Number > ')
  44.   IF temp=1 THEN
  45.     DO
  46.       lynes.=''
  47.       IF EXISTS(prodir'/'name) THEN
  48.         DO
  49.           IF readlines(prodir'/'name 1)~=0 THEN ITERATE lupe
  50.           CALL DELETE(prodir'/'name)
  51.         END
  52.       ELSE lynes.0=3
  53.       lynes.1=name
  54.       lynes.2='Profile Last Updated:' DATE('W') DATE() TIME('C')
  55.       lynes.3=LEFT('=',74,'=')
  56.       IF savelines(prodir'/'name)~=0 THEN
  57.         DO
  58.           line='Profile for' name 'failed to save!'
  59.           SAY line||CR
  60.           CALL send2log(line)
  61.           ITERATE lupe
  62.         END
  63.       edtype=''
  64.       CALL bbsEd.rexx(4 prodir'/'name name TRUNC(maxtime-TIME('E'))-28)
  65.       IF readlines(prodir'/'name 1)~=0 THEN CALL DELETE(prodir'/'name)
  66.       IF lynes.0<4 THEN CALL DELETE(prodir'/'name)
  67.       pros=SHOWDIR(prodir)
  68.     END
  69.   ELSE IF temp=2 THEN
  70.     DO pf=1
  71.       totpros=WORDS(pros)
  72.       DO pfl=1 TO totpros BY 3
  73.         pfl2=pfl+1
  74.         pfl3=pfl+2
  75.         pfline=pen3||RIGHT(pfl,3)||def LEFT(WORD(pros,pfl),21)
  76.         IF pfl2<=totpros THEN
  77.           pfline=pfline pen3||RIGHT(pfl2,3)||def LEFT(WORD(pros,pfl2),21)
  78.         IF pfl3<=totpros THEN
  79.           pfline=pfline pen3||RIGHT(pfl3,3)||def LEFT(WORD(pros,pfl3),21)
  80.         SAY pfline||CR
  81.         IF nonstop~=1 & ((pfl3%3)//linesperpage)=0 & pfl<totpros THEN
  82.           IF waiting(2) THEN LEAVE pfl
  83.       END
  84.       emnum=getinput(1 0 pen3'Select User Profile Number > 'def)
  85.       IF DATATYPE(emnum,'W') & emnum>0 & emnum<=totpros THEN
  86.         DO
  87.           tmp=WORD(pros,emnum)
  88.           IF level>sysoplevel THEN
  89.             DO
  90.               CALL bbsEd.rexx(1 prodir'/'tmp name TRUNC(maxtime-TIME('E'))-28)
  91.               IF readlines(prodir'/'tmp 1)~=0 THEN CALL DELETE(prodir'/'tmp)
  92.               IF lynes.0<4 THEN CALL DELETE(prodir'/'tmp)
  93.               pros=SHOWDIR(prodir)
  94.             END
  95.           ELSE CALL showtext(prodir'/'tmp 1)
  96.         END
  97.       ELSE LEAVE pf
  98.     END
  99.   ELSE IF temp=3 | temp=4 THEN
  100.     DO
  101.       searcharg=''
  102.       nonstop=0
  103.       IF temp=3 THEN
  104.         DO
  105.           searcharg=STRIP(getinput(0 0 'Enter Search Phrase > '))
  106.           IF searcharg='' THEN ITERATE lupe
  107.         END
  108.       DO ui=1 TO WORDS(pros)
  109.         pro=prodir'/'WORD(pros,ui)
  110.         IF temp=3 THEN
  111.           IF textsearch(pro searcharg)=0 THEN ITERATE ui
  112.         SAY CR
  113.         CALL readlines(pro 1)
  114.         IF nonstop=1 THEN rnonstop=1
  115.         ELSE rnonstop=0
  116.         CALL seelines(2)
  117.         IF rnonstop THEN nonstop=1
  118.         ELSE IF waiting2()=1 THEN LEAVE ui
  119.         SAY CR
  120.         SAY CR
  121.       END
  122.     END
  123.   ELSE IF temp='' | LEFT(temp,1)='Q' THEN LEAVE lupe
  124. END
  125. EXIT
  126.  
  127.  
  128. textsearch:
  129. ARG sfile' 'sarg
  130. IF sarg='' THEN RETURN 0
  131. x=OPEN(f,sfile,'R')
  132. IF x=0 THEN RETURN 0
  133. stemp=UPPER(READCH(f,65000))
  134. CALL CLOSE(f)
  135. retflag=0
  136. IF POS(sarg,stemp)>0 THEN retflag=1
  137. RETURN retflag
  138.  
  139.  
  140. showtext:
  141. PARSE ARG arg .
  142. IF EXISTS(arg) THEN
  143.   DO
  144.     CALL readlines(arg 1)
  145.     CALL seelines(1)
  146.     nonstop=0
  147.     CALL waiting()
  148.   END
  149. RETURN
  150.  
  151.  
  152. readopen:
  153. PARSE ARG fname
  154. ok=OPEN(f,fname,'R')
  155. IF ok~=0 THEN RETURN 1
  156. line=fname 'failed to open for reading!'
  157. SAY line||CR
  158. RETURN 0
  159.  
  160.  
  161. seelines:
  162. DO i=1 TO lynes.0
  163.   SAY lynes.i||def||CR
  164.   IF i//linesperpage=0 THEN
  165.     IF waiting2() THEN LEAVE i
  166. END
  167. nonstop=0
  168. RETURN
  169.  
  170.  
  171. readlines:
  172. CALL CLOSE(f)
  173. PARSE ARG tempname readstart .
  174. IF ~readopen(tempname) THEN RETURN 1
  175. IF readstart<2 THEN lynes.=''
  176. DO ri=readstart
  177.   line=READLN(f)
  178.   IF EOF(f) THEN BREAK
  179.   lynes.ri=line
  180. END
  181. lynes.0=ri-1
  182. CALL CLOSE(f)
  183. DO ri=lynes.0 TO 0 BY -1 WHILE LENGTH(lynes.ri)=0 | LEFT(UPPER(lynes.ri),1)='/'
  184. END
  185. lynes.0=ri
  186. RETURN 0
  187.  
  188.  
  189. savelines:
  190. PARSE ARG tempname .
  191. ok=OPEN(f,tempname,'W')
  192. IF ok=0 THEN
  193.   DO
  194.     SAY '***' tempname 'failed to open for saving!'CR
  195.     RETURN 1
  196.   END
  197. DO wi=1 TO lynes.0
  198.   CALL WRITELN(f,lynes.wi)
  199. END
  200. CALL CLOSE(f)
  201. RETURN 0
  202.  
  203.  
  204. waiting:
  205. CALL checktime()
  206. IF waitchar='Q' THEN
  207.   DO
  208.     waitchar=''
  209.     RETURN
  210.   END
  211. waitchar=''
  212. IF nonstop=1 THEN RETURN
  213. OPTIONS PROMPT pen3'                       RETURN=Continue  'def
  214. PULL waitchar
  215. RETURN
  216.  
  217.  
  218. waiting2:
  219. CALL checktime()
  220. IF nonstop=1 THEN RETURN 0
  221. waitchar=getinput(1 1 pen3'   Q=Quit   N=Non-Stop   RETURN=Continue  'def)
  222. IF waitchar='N' THEN
  223.   DO
  224.     nonstop=1
  225.     SAY pen3'To EXIT non-stop scrolling of text, press CTRL-E        'def||CR
  226.     SAY CR
  227.     CALL DELAY(100)
  228.     waitchar=''
  229.   END
  230. IF waitchar='Q' THEN RETURN 1
  231. RETURN 0
  232.  
  233.  
  234. getinput:
  235. PARSE ARG upflag' 'oneflag' 'pline
  236. CALL checktime()
  237. OPTIONS PROMPT pline
  238. PARSE PULL inarg
  239. inarg=STRIP(inarg)
  240. IF upflag THEN inarg=UPPER(inarg)
  241. IF oneflag THEN inarg=LEFT(inarg,1)
  242. RETURN inarg
  243.  
  244.  
  245. checktime:
  246. IF ~frombb THEN RETURN
  247. IF TIME('E')>maxtime THEN EXIT 0
  248. IF TIME('E')>(maxtime-120) THEN SAY '*** Less than 2 minutes left! ***'CR
  249. MSG RIGHT(' ',66-LENGTH(name)) '1B'x'M'||''||''||' 'name' level 'level' '||''
  250. CALL checkdcd()
  251. RETURN
  252.  
  253.  
  254. checkdcd:
  255. IF ~frombb THEN RETURN
  256. dcd
  257. IF RC=0 THEN
  258.   DO
  259.     DO dcds=1 TO 3  /* 5 second delay */
  260.       CALL DELAY(50)
  261.       dcd
  262.       IF RC~=0 THEN RETURN
  263.     END
  264.     dcd
  265.     IF RC=0 THEN EXIT 0
  266.   END
  267. xmsg=GETCLIP('BBS_MESSAGE')
  268. IF xmsg~='' THEN
  269.   DO
  270.     SAY CR
  271.     SAY bak2' Message From BBBBS: 'def||CR
  272.     SAY xmsg||CR
  273.     SAY CR
  274.     CALL SETCLIP('BBS_MESSAGE')
  275.     CALL waiting()
  276.   END
  277. IF POS('G',GETCLIP('BBS_COMMAND'))>0 THEN EXIT
  278. RETURN
  279.  
  280.  
  281. send2log:
  282. PARSE ARG sendline
  283. IF ~frombb THEN RETURN
  284. logfile=bbspath'Logs/log.'DATE('S')
  285. fl='W'
  286. IF EXISTS(logfile) THEN fl='A'
  287. IF ~OPEN('log',logfile,fl) THEN
  288.   DO
  289.     IF ~OPEN('log',logfile,fl) THEN
  290.       DO
  291.         SAY 'failed to open log file'
  292.         RETURN
  293.      END
  294.   END
  295. CALL WRITELN('log','bbsProfiles:' sendline)
  296. CALL CLOSE('log')
  297. RETURN
  298.  
  299.  
  300. BREAK_E:
  301. i=999999
  302. ri=999999
  303. wi=999999
  304. RETURN
  305.  
  306.  
  307. BREAK_C:
  308. EXIT
  309.  
  310. /* bbsProfiles.rexx */
  311.